<template>
    <div class="aliPay">
        <van-nav-bar title="支付宝账号" left-arrow @click-left="goBack"></van-nav-bar>
        <div class="content">
            <div class="info">
                <label for="userName">姓名</label>
                <input type="text" v-model="userName" id="userName">
            </div>
            <div class="info">
                <label for="card-number">支付宝账号</label>
                <input type="text" v-model="alipay" id="card-number">
            </div>
            <div class="info">
                <label for="pay-password">支付密码</label>
                <input type="text" v-model="payPassword" id="pay-password">
            </div>
            <div class="forget-paypw">
                <router-link :to="{name: 'phoneLogin'}" tag="span">忘记支付密码？</router-link>
            </div>
            <div class="uploader-photo">
                <p class="text">请上传您的支付宝收款二维码图片（*JPG/PNG/JPEG）</p>
                <div class="file-style">
                    <img src="../../../assets/images/idcard-front.png" ref="upimg" alt="">
                    <input type="file" name="file" id="uploaderInput" accept="image/jpg,image/png,image/jpeg" @change="change">
                </div>
            </div>
            <div class="submit">
                <button type="submit" class="submit-btn">提交</button>
            </div>
        </div>
    </div>
</template>
<script>
import Vue from "vue"
import axios from "axios"
import {
    uploadFile
} from "../../../axios/api.js"
import {
    NavBar,
    Uploader,
} from "vant"
export default {
    components: {
        [NavBar.name]: NavBar,
        [Uploader.name]: Uploader,
    },
    data() {
        return {
            userName: "",
            alipay: "",
            payPassword: "",
        }
    },
    methods: {
        //返回上一页
        goBack() {
            this.$router.go(-1);
        },
        //选择图片后执行
        change(event) {
            let UpFile = new FormData();
            UpFile.append("file",document.querySelector('input[type=file]').files[0]);
            console.log(UpFile.get('file'))
            UpFile.append("type","1");
            uploadFile(UpFile).then(res=> {
                //this.$refs.upimg.src = res.data.data;
                console.log(res.data.data)
            })
        },
    }
}
</script>
<style lang="less" scoped>
.van-uploader {
    width: 90%;
}
.aliPay {
    background: #fff;
    .content {
        background: #fff;
        .info {
            text-align: left;
            margin: 0 15px;
            width: 90%;
            font-size: 14px;
            color: #323233;
            & > label {
                display: block;
                margin: 10px 0;
            }
            & > input {
                padding: 10px;
                width: 94%;
                border: none;
                border-radius: 20px;
                background: #efefef;
            }
        }
        .forget-paypw {
            margin: 15px 15px 0 15px;
            text-align: right;
            width: 90%;
            font-size: 14px;
            color: #323233;
        }
        .uploader-photo {
            text-align: left;
            margin: 0 15px;
            width: 90%;
            font-size: 14px;
            color: #323233;
            .text {
                margin: 10px 0;
                font-size: 12px;
            }
            .file-style {
                position: relative;
                display: inline-block;
                width: 3.07rem;
                height: 2.27rem;
                overflow: hidden;
                text-decoration: none;
                text-indent: 0;
                line-height: 20px;
                img {
                    display: block;
                    width: 3.07rem;
                    height: 2.27rem;
                }
                input {
                    position: absolute;
                    width: 100%;
                    height: 100%;
                    right: 0;
                    top: 0;
                    opacity: 0;
                }
            }
        }
        .submit {
            margin: .67rem auto 0 auto;
            width: 90%;
            background-color: #fff;
            color: #fff;
            font-size: 14px;
            .submit-btn {
                padding: 10px;
                width: 100%;
                height: 1.07rem;
                border: 0;
                border-radius: 20px;
                background: #ff976a;
                outline: none;
            }
        }
    }
}
</style>
